//
//  NSString+Check.m
//  ZhiXingUser
//
//  Created by KFJ on 2019/4/16.
//  Copyright © 2019 QiaoLi. All rights reserved.
//

#import "NSString+Check.h"

@implementation NSString (Check)
+ (BOOL)isPhoneNum:(NSString *)str{
    //手机号以13， 15，18开头，八个 \d 数字字符
    NSString *phoneRegex = @"^1+\\d{10}";
    NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
    return [phoneTest evaluateWithObject:str] && str.length == 11;
}
+ (BOOL)isNickName:(NSString *)str {
    NSString *regex = @"[\u4e00-\u9fa5]{2,4}";
    NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
    return [phoneTest evaluateWithObject:str];
}

+ (BOOL)isEmpty:(NSString *)str {
    if(!str) {
        return YES;
    }else {
        NSCharacterSet *set = [NSCharacterSet whitespaceAndNewlineCharacterSet];
        NSString *trimedString = [str stringByTrimmingCharactersInSet:set];
        if([trimedString length] == 0) {
            return YES;
        }else {
            return NO;
        }
    }
}

@end
